<div class="category-cloud-block">
    <ul class="accordion">
        <?php if (isset($CommodityCategoryArray)): ?>
            <?php foreach ($CommodityCategoryArray as $thisCommodityCategory): ?>
                <?php /** @var CommodityCategory $thisCommodityCategory */ ?>
                <?php if ($thisCommodityCategory->getFatherId() != 0) continue; ?>
                <li <?php if (isset($NowMasterCategoryId) && $NowMasterCategoryId == $thisCommodityCategory->getId()) echo 'class="now"' ?>>
                    <a href="<?php echo base_url('home/category/' . $thisCommodityCategory->getId()); ?>">
                        <img src="<?php echo base_url($thisCommodityCategory->getIconUrl()) ?>"/>
                        <?php echo $thisCommodityCategory->getName(); ?>
                        <span class="num"><?php echo $thisCommodityCategory->countDescendantCommodityWithSelf() ?></span>
                    </a>
                    <?php $flag = false; ?>
                    <?php foreach ($CommodityCategoryArray as $thisSubCommodityCategory): ?>
                <?php /** @var CommodityCategory $thisSubCommodityCategory */ ?>
                <?php if ($thisSubCommodityCategory->getFatherId() != $thisCommodityCategory->getId()) continue; ?>
                <?php if (!$flag) : ?>
                <?php $flag = true; ?>
                    <ul class="sub-menu" style="display: none;">
                        <li <?php if (isset($NowCategoryId) && $NowCategoryId == $thisSubCommodityCategory->getId()) echo 'class="now"' ?>>
                            <a href="<?php echo base_url('home/category/' . $thisSubCommodityCategory->getId()); ?>">
                                <img src="<?php echo base_url($thisSubCommodityCategory->getIconUrl()) ?>" style="margin-top:1px;"/>
                                <?php echo $thisSubCommodityCategory->getName(); ?>
                                <span class="num"><?php echo $thisSubCommodityCategory->countDescendantCommodityWithSelf() ?></span>
                            </a>
                        </li>
                        <?php else: ?>
                            <li <?php if (isset($NowCategoryId) && $NowCategoryId == $thisSubCommodityCategory->getId()) echo 'class="now"' ?>>
                                <a href="<?php echo base_url('home/category/' . $thisSubCommodityCategory->getId()); ?>">
                                    <img src="<?php echo base_url($thisSubCommodityCategory->getIconUrl()) ?>" style="margin-top:1px;"/>
                                    <?php echo $thisSubCommodityCategory->getName(); ?>
                                    <span class="num"><?php echo $thisSubCommodityCategory->countDescendantCommodityWithSelf() ?></span>
                                </a>
                            </li>
                        <?php
                        endif;
                        ?>
                        <?php endforeach; ?>
                        <?php if ($flag) : ?>
                    </ul>
                <?php endif; ?>
                </li>
            <?php endforeach; ?>
        <?php endif; ?>
    </ul>
</div>

<div class="recommend">
    <div class="title">
        <h4>物品推荐<span style="font-size:12px; font-weight:normal; letter-spacing:1px; color:#ACACAC">(点赞排名)</span></h4>
    </div>
    <ul>
        <?php if (isset($PlusOneTop10CommodityArray)): ?>
            <?php foreach ($PlusOneTop10CommodityArray as $thisCommodity): ?>
                <?php /** @var Commodity $thisCommodity */ ?>
                <li><a href="<?php echo base_url('home/details/' . $thisCommodity->getId()) ?>"><?php echo $thisCommodity->getTitle() ?></a></li>
            <?php endforeach; ?>
        <?php endif; ?>
    </ul>
</div>

<div class="latest">
    <div class="title">
        <h4>最新发布<span style="font-size:12px; font-weight:normal; letter-spacing:1px; color:#ACACAC">(时间排名)</span></h4>
    </div>
    <ul>
        <?php if (isset($LatestReleaseTop10CommodityArray)): ?>
            <?php foreach ($LatestReleaseTop10CommodityArray as $thisCommodity): ?>
                <?php /** @var Commodity $thisCommodity */ ?>
                <li><a href="<?php echo base_url('home/details/' . $thisCommodity->getId()) ?>"><?php echo $thisCommodity->getTitle() ?></a></li>
            <?php endforeach; ?>
        <?php endif; ?>
    </ul>
</div>

<!--分类列表-->
<script type="text/javascript">
    $(document).ready(function () {
        $('.accordion > li').on('mouseenter', function (event) {
            if (!$(this).hasClass('now'))
                $(this).find('.sub-menu').stop().clearQueue().slideDown();
            $(this).addClass('active');
        });
        $('.accordion > li').on('mouseleave', function (event) {
            if (!$(this).hasClass('now'))
                $(this).find('.sub-menu').stop().clearQueue().slideUp();
            $(this).removeClass('active');
        });
    });
</script>
